package com.gamemost.templestay;

import java.io.File;
import java.util.ArrayList;

import com.gamemost.entity.DownloadedBook;
import com.gamemost.entity.Index;
import com.gamemost.layout.BookmarkAdapter;
import com.gamemost.layout.IndexesAdapter;
import com.gamemost.layout.LayoutViewReadBook;
import com.gamemost.managers.ResourcesManager;
import com.gamemost.templestay.R;

import android.app.Activity;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ListView;
import android.widget.TextView;

public class IndexesActivity extends Activity{
	ListView lv_index;
	public IndexesAdapter mAdapter;
	public BookmarkAdapter bmAdapter;
	public TextView tv_index,tv_bookmark;
	public static IndexesActivity ac;
	public ArrayList<Index> list = new ArrayList<Index>();
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.index_view);
		ac = this;
		mAdapter = new IndexesAdapter(this);
		lv_index = (ListView)this.findViewById(R.id.listview_index);
		tv_index = (TextView)this.findViewById(R.id.tab_index);
		tv_bookmark = (TextView)this.findViewById(R.id.tab_mark);
		mAdapter.setList(LayoutViewReadBook.getInstance().tableContent.getTableContent());
		lv_index.setAdapter(mAdapter);
		DownloadedBook book = LayoutViewReadBook.getInstance().getCurrentBookReading();
		ArrayList<String> list = book.getListString();
		bmAdapter = new BookmarkAdapter(this);
		bmAdapter.setData(book.getBookmark(), list);
		bmAdapter.setData(LayoutViewReadBook.getInstance().getCurrentBookReading());
		tv_bookmark.setOnClickListener(new OnClickListener() {			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub				
				tv_bookmark.setBackgroundResource(R.color.bluesky);
				tv_index.setBackgroundResource(R.color.white);
				lv_index.setAdapter(bmAdapter);
			}
		});
		tv_index.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub				
				tv_bookmark.setBackgroundResource(R.color.white);
				tv_index.setBackgroundResource(R.color.bluesky);
				lv_index.setAdapter(mAdapter);
			}
		});
		
	}
}
